<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<html>
<head>
    <title>园区门禁管理系统</title>
    <style>
        .mydiv{
            width: 500px;
            text-align: center;
            margin: 0 auto;
        }
        .mydiv table{
            width: 500px;
            text-align: center;
            margin: 0 auto;
            border-collapse: collapse;
        }
        .mydiv table td{line-height: 30px;}
        .title{
            font-size: 28px;
            line-height: 48px;
        }
        select{width: 180px;}
    </style>
</head>

<body>
    <div class="mydiv">
        <form action="<%=request.getContextPath()%>/doadd" method="post">
            <table border="1">
                <tr style="background-color: aqua;">
                    <td colspan="5">
                        <p class="title">园区门禁管理系统</p>
                    </td>
                </tr>
                <tr>
                    <td>负责人(*)：</td>
                    <td><input type="text" name="principal" id="principal"></td>
                </tr>
                <tr>
                    <td>供应商(*)：</td>
                    <td><input type="text" name="supplier" id="supplier"></td>
                </tr>
                <tr>
                    <td>品牌(*)：</td>
                    <td><input type="text" name="brand" id="brand"></td>
                </tr>
                <tr>
                    <td>所属楼宇(*)：</td>
                    <td>
                        <select class="buidingId" name="buidingId">
                            <option value="0">请选择</option>
                            <c:forEach items="${bList}" var="b">
                                <option value="${b.id}">${b.name}</option>
                            </c:forEach>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>安装日期(*)：</td>
                    <td><input type="date" name="addTime" id="addTime"></td>
                </tr>
                <tr>
                    <td colspan="5">
                        <input type="submit" value="提交" class="mysub">
                        <input type="button" value="返回" id="back" name="back">
                    </td>
                </tr>
            </table>
        </form>
    </div>
</body>


<script src="<%=request.getContextPath()%>/js/jQuery.js"></script>
<script>
    $("#back").click(function () {
        window.location.href = "<%=request.getContextPath()%>/index";
    });
    $(".mysub").click(function () {
        //获取值
        var principal = $("#principal").val();
        var supplier = $("#supplier").val();
        var brand = $("#brand").val();
        var hospitalId = $(".hospitalId").val();
        var addTime = $("#addTime").val();

        if (principal === "" || supplier === "" || brand === "" || hospitalId === "" || addTime === "") {
            alert("请填写完整的门禁设备信息!");
        } else {
            alert("新增成功!");
        }
    })
</script>
</html>
